<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/7/15
 * Time: 10:18
 */
namespace app\admin\controller;
use think\Db;
use think\Request;
class Order extends Base {
    /**
     * 列表展示
     * @return mixed|\think\response\Json
     */
    public function index()
    {
        if (request()->isAjax()) {
            extract(input());
            $map =array();
            if(isset($province)&&$province!="")
            {
                $map['a.order_type'] = $province;
            }
            if(isset($keyword)&&$keyword!="")
            {
                $map['uuu.user_username,uuu.user_phone'] = array('like',"&$keyword&");
            }
            $map['order_status'] = 2;
            $NowPage = input('page') ? input('page') : 1;
            $limits = input("limit") ? input("limit") : 10;
            $count = Db::name('order')->alias('a')
                ->join('up_u_user uuu','uuu.user_id = a.order_userid','left')
                ->where($map)
                ->count();// 获取总条数
            $lists = Db::name('order')->alias('a')
                ->join('up_u_user uuu','uuu.user_id = a.order_userid','left')
                ->field('user_username,user_phone,a.*')
                ->page($NowPage, $limits)
                ->order('a.order_paytime desc')
                ->where($map)
                ->select();
            return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
        }
        return $this->fetch();
    }
}